package org.alfalfa.utils;

import common.LogicLong;
import common.RandomIdentifiers;
import common.StringUtils;
import messages.Login;

/**
 * @Author : Max-Goday
 * @Created : 2016-10-21
 * @E-mail : goday.max@gmail.com
 * @Version : 1.0
 */
public class AppUtils {

	public static Login createNewFarm(Integer version, String masterhash) {
		Login lmsg = new Login();
		lmsg.AccountID = new LogicLong(0L);
		lmsg.PassToken = null;
		if(masterhash != null) {
			lmsg.ResourceFingerPrint = masterhash;
		} else {
			lmsg.ResourceFingerPrint = "1ed0f3cb6bbc25c5c4855fc5dc5567979aa8a754";
		}

		if(version != null) {
			lmsg.VersionNumber = version.intValue();
		} else {
			lmsg.VersionNumber = 1078368;
		}

		lmsg.UDID = "";
		byte[] farmid = RandomIdentifiers.getNextAndroidID();
		lmsg.OpenUDID = StringUtils.hexToString(farmid);
		lmsg.MacAddress = StringUtils.macAddrStyle(RandomIdentifiers.getNextMACAddress());
		lmsg.Device = "Sony Xperia Z2";
		lmsg.ADID = RandomIdentifiers.getNextAdvertisingID(farmid);
		lmsg.add123present = 1;
		lmsg.FirmwareVersion = "4.4";
		lmsg.add1 = "";
		lmsg.add2 = lmsg.OpenUDID;
		lmsg.add3 = "EN";
		lmsg.add4 = "";
		lmsg.add5 = Byte.valueOf((byte)1);
		lmsg.add6 = "";
		lmsg.add7 = Integer.valueOf(2);
		return lmsg;
	}

	public static Login getFarmWithIdAndToken(Integer version, String masterhash, long accountId, String passToken) {
		Login lmsg = new Login();
		lmsg.AccountID = new LogicLong(accountId);
		lmsg.PassToken = passToken;
		if(masterhash != null) {
			lmsg.ResourceFingerPrint = masterhash;
		} else {
			lmsg.ResourceFingerPrint = "1ed0f3cb6bbc25c5c4855fc5dc5567979aa8a754";
		}

		if(version != null) {
			lmsg.VersionNumber = version.intValue();
		} else {
			lmsg.VersionNumber = 1078368;
		}

		lmsg.UDID = "";
		byte[] farmid = RandomIdentifiers.getNextAndroidID();
		lmsg.OpenUDID = StringUtils.hexToString(farmid);
		lmsg.MacAddress = StringUtils.macAddrStyle(RandomIdentifiers.getNextMACAddress());
		lmsg.Device = "Sony Xperia Z2";
		lmsg.ADID = RandomIdentifiers.getNextAdvertisingID(farmid);
		lmsg.add123present = 1;
		lmsg.FirmwareVersion = "4.4";
		lmsg.add1 = "";
		lmsg.add2 = lmsg.OpenUDID;
		lmsg.add3 = "EN";
		lmsg.add4 = "";
		lmsg.add5 = Byte.valueOf((byte)1);
		lmsg.add6 = "";
		lmsg.add7 = Integer.valueOf(2);
		return lmsg;
	}

}
